<script>
/**
 * 图标按钮
 *    props: { 'icon-only': bool }
 *    data: el-button-data
 */
export default {
  name: 'YmIconButton',
  functional: true,
  render (h, context) {
    const { props, data, listeners } = context
    if (props['icon-only']) {
      return h('i', {
        ...data,
        'class': props.icon,
        on: listeners
      })
    }
    // 显示标题
    let label = context.children || props.label || ''

    return h(
      'el-button',
      {
        ...data,
        on: {
          ...listeners,
          click: () => {
            if (listeners.click) listeners.click(props)
          }
        }
      }, label
    )
  }
}
</script>
